let Utils = require("../../../framework/js/utils");

window.AUI.customCompoents.define("aui-radiogroup", class extends window.AUI.BaseComponent {
    constructor(name) {
        super(name);
        this.props = {
            radios: {
                type: Array
            },
            value: {
                required: true
            },
            inline: {
                type: Boolean,
                default: true
            }
        };
        this.methods = {
            handleChange(e) {
                this.$emit("input", e.target.value);
            }
        }
    }
    _template() {
        var self = this;
return `<div class="${self._name}">
    <div class="radio">
        <label :class="{'checkbox-inline': inline}" v-for="radio in radios">           
            <input type="radio" :name="radioname" @change="handleChange" :value="radio.value"
                :checked="radio.value == value" >
            <span v-html="radio.label"></span>
        </label>           
    </div>
</div>`;
    }
    _data() {
        var ret = {};
        ret.radioname = Utils.uniqueSelector("radio_");
        return ret;
    }
});